
%This script converts the model from a stoichiometric matrix with 
%One complex per reaction, and all reactions reversible to a model 
%With no repeated complexes and all reactions reversible

%Given a stoichiometric matrix S, and a set of reaction rates k_f,k_r
m = size(S,1);
s = size(S,2);

FR = [max(S,0),max(-S,0)];
k = [kf,kr];
%flag of visited complexes
F = zeros(1,2*s);
%Identifications
Idt = [];
Id = zeros(2*s,1);

for i=1:2*s
	if(F(i)==0)
		for j = i:2*s
			if(F(j) == 0 && FR(:,i) == FR(:,j))
				Id(j) = 1;
				F(j) =1;
			end	
		end
		Idt = [Idt,Id];
	end
end
A = Idt'*diag(k)*Idt;
%Initial adjacency matrix

